﻿using AIO.Entity.Base;
using AIO.IService;
using AIO.IService.Base;

namespace AIO.Service.Base
{
    /// <summary>
    /// 仓库包装器
    /// </summary>
    public class RepositoryWrapper : IRepositoryWrapper
    {
        private readonly ApiDBContext _dbContext;

        public RepositoryWrapper(ApiDBContext dbContext)
        {
            _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
        }

        public Task<int> Save()
        {
            return Task.FromResult(0);
        }

        private IStudentRepository? _studentRepository;

        private IDepartmentRepository? _departmentRepository;
        private IAccountRepository? _accountRepository;
        private IEquipRepostory? _equipRepsitory;
        private IClassroomRepository? _classroomRepository;
        private ITeacherRepository? _teacherRepository;
        private EquipMaintenanceRepository _euipMaintenanceRepository;
        private EquipMaintenanceRepository _equipMaintenanceRepository;

        private TeacherAttenderRepository _TeacherAttenderRepository;

        private IPayInfoRepository? _payInfoRepository;

        private IDormitoryManagerRepository? _DormitoryManagerRepository;
        private ITimeTableRepository? _timetableRepository;
        private IReportingRepository? _reportingRepository;
        /// <summary>
        /// 学生
        /// </summary>
        public IStudentRepository StudentRepository
        {
            get { return _studentRepository ??= new StudentRepository(_dbContext); }
        }
        /// <summary>
        /// 系部
        /// </summary>
        public IDepartmentRepository DepartmentRepository
        {
            get { return _departmentRepository ??= new DepartmentRepository(_dbContext); }
        }
        /// <summary>
        /// 账户
        /// </summary>
        public IAccountRepository AccountRepository
        {
            get { return _accountRepository ??= new AccountRepository(_dbContext); }
        }

        public IEquipRepostory EquipRepsitory
        {
            get { return _equipRepsitory ??= new EquipRepsitory(_dbContext); }
        }

        public IEquipRepostory EquipRepostory{
            get { return _equipRepsitory ??= new EquipRepsitory(_dbContext); }
        }

        public IClassroomRepository ClassroomRepository
        {
            get { return _classroomRepository ??= new ClassroomRepository(_dbContext); }
        }

        public ITeacherRepository TeacherRepository
        {
            get { return _teacherRepository ??= new TeacherRepository(_dbContext); }
        }

        public IEquipMaintenanceRepository EquipMaintenanceRepository
        {
            get { return _equipMaintenanceRepository ??= new EquipMaintenanceRepository(_dbContext); }
        }

        public ITeacherAttenderRepository TeacherAttenderRepository{
            get { return _TeacherAttenderRepository ??= new TeacherAttenderRepository(_dbContext); }
        }

        public IPayInfoRepository PayInfoRepository
        {
            get { return _payInfoRepository ??= new PayInfoRepository(_dbContext); }
        }

        public IDormitoryManagerRepository DormitoryManagerRepository
        {
            get { return _DormitoryManagerRepository ??= new DormitoryManagerRepository(_dbContext); }
        }

        public ITimeTableRepository TimeTableRepository
        {
            get { return _timetableRepository ??= new TimeTableRepository(_dbContext); }
        }
        public IReportingRepository ReportingRepository
        {
            get { return _reportingRepository ??= new ReportingRepository(_dbContext); }
        }
    }
}
